<template>
	<view class="calculator">
		<view class="container">
			<view class="titleTip">房贷计算器</view>
			<view class="header">
				<view class="headerInner">
					<view class="radio" @tap="selectClick(0)">
						<icon :type="select == '0' ? 'success' : 'circle'" size="22" color="#09BB07" />
						<text>商业贷款</text>
					</view>
					<view class="radio" @tap="selectClick(1)">
						<icon :type="select == '1' ? 'success' : 'circle'" size="22" color="#09BB07" />
						<text>公积金贷款</text>
					</view>
					<view class="radio" @tap="selectClick(2)">
						<icon :type="select == '2' ? 'success' : 'circle'" size="22" color="#09BB07" />
						<text>组合贷款</text>
					</view>
				</view>
			</view>
			<view class="content">
				<view class="title">计算方式：</view>
				<form v-if="select == '0' || select == '1'" @submit="singleSubmit" @reset="singleReset">
					<view class="contentInner">
						<view class="innerTip" @tap="tabClick('area')">
							<icon :type="iconIndex == 'area' ? 'success' : 'circle'" size="22" color="#09BB07" />
							<text>根据面积、单位计算</text>
						</view>
						<view class="area" v-if="iconIndex == 'area'">
							<view class="areaItem">
								<text>单价：</text>
								<input type="text" name="price1" />
								<text>元/平米</text>
							</view>
							<view class="areaItem">
								<text>面积：</text>
								<input type="text" name="area1" />
								<text>平米</text>
							</view>
							<view class="areaItem">
								<text>按揭成数：</text>
								<picker rect @change="mortgage1number" :range="mortgage1number_arr">
									<view class="rect">
										{{ curMortgage1number }}
										<view class="triangle"></view>
									</view>
								</picker>
							</view>
						</view>
						<view class="innerTip" @tap="tabClick('loan')">
							<icon :type="iconIndex == 'loan' ? 'success' : 'circle'" size="22" color="#09BB07" />
							<text>根据贷款总额计算</text>
						</view>
						<view class="loan" v-if="iconIndex == 'loan'">
							<view class="areaItem">
								<text>贷款总额：</text>
								<input type="text" name="price2" />
								<text>元</text>
							</view>
						</view>
						<view class="line"></view>
						<view class="contentMid">
							<view class="areaItem">
								<text>按揭年数：</text>
								<picker rect @change="mortgage1Year" :range="mortgage1Year_arr">
									<view class="rect">
										{{ curMortgage1Year }}
										<view class="triangle"></view>
									</view>
								</picker>
							</view>
							<view class="areaItem">
								<text>贷款利率：</text>
								<picker rect @change="loan1interestRate" :range="loan1interestRate_arr">
									<view class="rect">
										{{ curLoan1interest }}
										<view class="triangle"></view>
									</view>
								</picker>
							</view>
							<view class="areaItem">
								<text></text>
								<text class="percentText">{{ perceNum1 }}</text>
								<text>%</text>
							</view>
						</view>
						<view class="line"></view>
						<view class="contentBom">
							<text>还款方式：</text>

							<radio-group class="radio-group" @change="equal1Radios">
								<label class="radio1" v-for="(item, index) in equal1Radios_arr" :key="index">
									<radio :value="item.name" :checked="item.checked" />
									{{ item.value }}
								</label>
							</radio-group>
						</view>
						<view class="line"></view>
						<view class="contentBtn">
							<button form-type="submit" type="primary">开始计算</button>
							<button form-type="reset" type="default">重新填写</button>
						</view>
					</view>
				</form>
				<form v-if="select == '2'" @submit="combinationSubmit" @reset="combinationReset">
					<view class="contentInner">
						<view class="innerTip">
							<icon type="success" size="22" color="#09BB07" @tap="tabClick('area')"></icon>
							<text>根据面积、单位计算</text>
						</view>
						<view class="area">
							<view class="areaItem">
								<text>商业性：</text>
								<input type="text" name="businessMoney" />
								<text>元</text>
							</view>
							<view class="areaItem">
								<text>公积金：</text>
								<input type="text" name="accumfundMoney" />
								<text>元</text>
							</view>
						</view>
						<view class="line"></view>
						<view class="contentMid">
							<view class="areaItem">
								<text>按揭年数：</text>
								<picker rect @change="mortgage1Year" :range="mortgage1Year_arr">
									<view class="rect">
										{{ curMortgage1Year }}
										<view class="triangle"></view>
									</view>
								</picker>
							</view>
							<view class="areaItem">
								<text>贷款利率：</text>
								<picker rect @change="loan1interestRate" :range="loan1interestRate_arr">
									<view class="rect">
										{{ curLoan1interest }}
										<view class="triangle"></view>
									</view>
								</picker>
							</view>
							<view class="areaItem">
								<text>商业性：</text>
								<text class="percentText">{{ perNum2F }}</text>
								<text>%</text>
							</view>
							<view class="areaItem">
								<text>公积金：</text>
								<text class="percentText">{{ perNum2S }}</text>
								<text>%</text>
							</view>
						</view>
						<view class="line"></view>
						<view class="contentBom">
							<text>还款方式：</text>
							<radio-group class="radio-group" @change="equal1Radios">
								<label class="radio1" v-for="(item, index) in equal1Radios_arr" :key="index">
									<radio :value="item.name" :checked="item.checked" />
									{{ item.value }}
								</label>
							</radio-group>
						</view>
						<view class="line"></view>
						<view class="contentBtn">
							<button form-type="submit" type="primary">开始计算</button>
							<button form-type="reset" type="default">重新填写</button>
						</view>
					</view>
				</form>
			</view>
			<view class="footer">
				<view class="footerInner">
					<view class="footerTitle">查看结果：</view>
					<view class="footerContent">
						<view class="footerItem">
							<text>房款总额：</text>
							<text>{{ houseAmout }}</text>
							<text>元</text>
						</view>
						<view class="footerItem">
							<text>贷款总额：</text>
							<text>{{ loanAmount }}</text>
							<text>元</text>
						</view>
						<view class="footerItem">
							<text>还款总额：</text>
							<text>{{ repayAmount }}</text>
							<text>元</text>
						</view>
						<view class="footerItem">
							<text>支付利息款：</text>
							<text>{{ repayInterest }}</text>
							<text>元</text>
						</view>
						<view class="footerItem">
							<text>首期付款：</text>
							<text>{{ firstRepay }}</text>
							<text>元</text>
						</view>
						<view class="footerItem">
							<text>贷款月数：</text>
							<text>{{ loanMonth }}</text>
							<text>月</text>
						</view>
						<block v-for="(item, index) in monthArray" :key="index" v-if="monthArray.length < 6 && monthArray.length > 1">
							<view class="footerItem">
								<text>第{{ index + 1 }}个月还款：</text>
								<text>{{ item }}</text>
								<text>元</text>
							</view>
						</block>
						<block v-for="(item, index) in monthArray" :key="index" v-if="monthArray.length == 1">
							<view class="footerItem">
								<text>每月还款：</text>
								<text>{{ item }}</text>
								<text>元</text>
							</view>
						</block>
						<scroll-view scroll-y style="height:480upx;" v-if="monthArray.length >= 6">
							<block v-for="(item, index) in monthArray" :key="index">
								<view class="footerItem">
									<text>第{{ index + 1 }}个月还款：</text>
									<text>{{ item }}</text>
									<text>元</text>
								</view>
							</block>
						</scroll-view>
					</view>
					<view class="footerTip">*以上结果仅供参考</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			iconIndex: 'area',
			mortgage1number_arr: ['9成', '8成', '7成', '6成', '5成', '4成', '3成', '2成'],
			mortgage1numberNum: [0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2],
			mortgage1numberCurr: '',
			curMortgage1number: '',
			mortgage1Year_arr: [
				'1年(12期)',
				'2年(24期)',
				'3年(36期)',
				'4年(48期)',
				'5年(60期)',
				'6年(72期)',
				'7年(84期)',
				'8年(96期)',
				'9年(108期)',
				'10年(120期)',
				'11年(132期)',
				'12年(144期)',
				'13年(156期)',
				'14年(168期)',
				'15年(180期)',
				'16年(192期)',
				'17年(204期)',
				'18年(216期)',
				'19年(228期)',
				'20年(240期)',
				'25年(300期)',
				'30年(360期)'
			],
			curMortgage1Year: '',
			curMortgage1YearNum: '',
			loan1interestRate_arr: [
				'2018年6月1日基准利率',
				'2018年6月1日基准利率上限(1.3倍)',
				'2018年6月1日基准利率上限(1.2倍)',
				'2018年6月1日基准利率上限(1.1倍)',
				'2018年6月1日基准利率上限(85折)',
				'2018年6月1日基准利率上限(7折)'
			],
			curLoan1interest: '',
			loan1interestRateNum: [1, 1.3, 1.2, 1.1, 0.85, 0.7],
			curLoan1interestIndex: 0,
			select: '0',
			equal1Radios_arr: [{ name: 'equal1Interest', value: '等额本息', checked: 'true' }, { name: 'equal1Money', value: '等额本金' }],
			curEqual1item: '',
			perceItem: [{ business: 4.35, accumfund: 2.75 }, { business: 4.75, accumfund: 2.75 }, { business: 4.9, accumfund: 3.25 }],
			perceNum1: '',
			perNum2F: '',
			perNum2S: '',
			houseAmout:'',
			loanAmount:'',
			repayAmount:'',
			repayInterest:'',
			firstRepay:'',
			loanMonth:'',
			monthArray:''
		};
	},
	created(options) {
		this.resetData();
	},
	methods: {
		resetData() {
			this.curMortgage1number = this.mortgage1number_arr[0];
			this.curMortgage1Year = this.mortgage1Year_arr[0];
			this.curMortgage1YearNum = 1;
			this.curLoan1interest = this.loan1interestRate_arr[0];
			this.curEqual1Radio = this.equal1Radios_arr[0].name;
			this.perceNum1 = this.perceItem[0].business;
			this.curEqual1item = this.equal1Radios_arr[0].name;
			this.perNum2F = this.perceItem[0].business;
			this.perNum2S = this.perceItem[0].accumfund;
			this.mortgage1numberCurr = this.mortgage1numberNum[0];
			this.houseAmout = '';
			this.loanAmount = '';
			this.repayAmount = '';
			this.repayInterest = '';
			this.firstRepay = '';
			this.loanMonth = '';
			this.monthArray = [];
			this.caculateDat = false;
		},

		//计算方式
		tabClick(e) {
			this.iconIndex = e;
			this.caculateData = false;
			this.houseAmout = '';
			this.loanAmount = '';
			this.repayAmount = '';
			this.repayInterest = '';
			this.firstRepay = '';
			this.loanMonth = '';
			this.monthArray = [];
		},
		//选择类型
		selectClick(e) {
			this.select = e;
			this.caculateData = false;
			this.resetData();
			this.calculaPerce();
		},

		//计算百分比
		calculaPerce() {
			var currNum = this.curMortgage1Year.indexOf('年');
			var currYear = parseInt(this.curMortgage1Year.substring(0, currNum)),
				perNum,
				perNum2f,
				perNum2s;
			if (this.select == 0) {
				if (currYear == 1) {
					perNum = (this.perceItem[0].business * this.loan1interestRateNum[this.curLoan1interestIndex]).toFixed(2);
				} else if (currYear >= 6) {
					perNum = (this.perceItem[2].business * this.loan1interestRateNum[this.curLoan1interestIndex]).toFixed(2);
				} else {
					perNum = (this.perceItem[1].business * this.loan1interestRateNum[this.curLoan1interestIndex]).toFixed(2);
				}
			} else if (this.select == 1) {
				if (currYear <= 5) {
					perNum = this.perceItem[0].accumfund.toFixed(2);
				} else {
					perNum = this.perceItem[2].accumfund.toFixed(2);
				}
			} else {
				if (currYear == 1) {
					perNum2f = (this.perceItem[0].business * this.loan1interestRateNum[this.curLoan1interestIndex]).toFixed(2);
					perNum2s = this.perceItem[0].accumfund.toFixed(2);
				} else if (currYear >= 6) {
					perNum2f = (this.perceItem[2].business * this.loan1interestRateNum[this.curLoan1interestIndex]).toFixed(2);
					perNum2s = this.perceItem[2].accumfund.toFixed(2);
				} else {
					perNum2f = (this.perceItem[1].business * this.loan1interestRateNum[this.curLoan1interestIndex]).toFixed(2);
					perNum2s = this.perceItem[0].accumfund.toFixed(2);
				}
			}

			this.perceNum1 = perNum;
			this.perNum2F = perNum2f;
			this.perNum2S = perNum2s;
			this.curMortgage1YearNum = currYear;
		},
		// 按揭成数1
		mortgage1number(e) {
			this.curMortgage1number = this.mortgage1number_arr[e.detail.value];
			this.mortgage1numberCurr = this.mortgage1numberNum[e.detail.value];
		},
		//按揭年数1
		mortgage1Year(e) {
			this.curMortgage1Year = this.mortgage1Year_arr[e.detail.value];
			this.calculaPerce();
		},
		//贷款利率1
		loan1interestRate(e) {
			this.curLoan1interest = this.loan1interestRate_arr[e.detail.value];
			this.curLoan1interestIndex = e.detail.value;
			this.calculaPerce();
		},
		// 还款方式1
		equal1Radios(e) {
			this.curEqual1item = e.detail.value;
			this.caculateData = false;
			this.houseAmout = '';
			this.loanAmount = '';
			this.repayAmount = '';
			this.repayInterest = '';
			this.firstRepay = '';
			this.loanMonth = '';
			this.monthArray = [];
		},
		//单个提交
		singleSubmit(e) {
			if (this.select != 2) {
				if (this.iconIndex == 'area') {
					this.verificationInfo(e.detail.value.price1, e.detail.value.area1, 'price2', 'businessMoney', 'accumfundMoney');
					if (this.caculateData) {
						this.busineFund(e.detail.value.price1, e.detail.value.area1, '', this.mortgage1numberCurr, this.curMortgage1YearNum, this.perceNum1);
					}
				} else {
					this.verificationInfo('price', 'area', e.detail.value.price2, 'businessMoney', 'accumfundMoney');
					if (this.caculateData) {
						this.busineFund('', '', e.detail.value.price2, '', this.curMortgage1YearNum, this.perceNum1);
					}
				}
			} else {
			}
		},
		singleReset(e) {
			this.resetData();
			this.curEqual1item = '';
		},
		combinationSubmit(e) {
			if (this.select == 2) {
				this.verificationInfo('price', 'area', 'price2', e.detail.value.businessMoney, e.detail.value.accumfundMoney);
				if (this.caculateData) {
					this.combinationCaculate(e.detail.value.businessMoney, e.detail.value.accumfundMoney, this.curMortgage1YearNum, this.perNum2F, this.perNum2S);
				}
			}
		},
		combinationReset(e) {
			this.resetData();
			this.curEqual1item = '';
		},
		verificationInfo(price, area, price2, businessMoney, accumfundMoney) {
			if (!price) {
				uni.showModal({
					title: '消息',
					content: '单价不能为空',
					showCancel: false
				});
				return;
			}
			if (!area) {
				uni.showModal({
					title: '消息',
					content: '面积不能为空',
					showCancel: false
				});
				return;
			}
			if (!price2) {
				uni.showModal({
					title: '消息',
					content: '贷款总额不能为空',
					showCancel: false
				});
				return;
			}
			if (!businessMoney) {
				uni.showModal({
					title: '消息',
					content: '商业性金额不能为空',
					showCancel: false
				});
				return;
			}
			if (!accumfundMoney) {
				uni.showModal({
					title: '消息',
					content: '公积金金额不能为空',
					showCancel: false
				});
				return;
			}
			if (!this.curEqual1item) {
				uni.showModal({
					title: '消息',
					content: '还款方式不能为空',
					showCancel: false
				});
				return;
			}

			this.caculateData = true;
		},
		//商业贷款与公积金贷款
		busineFund(perPrice, area, loan, percentage, year, interest) {
			let monthArray = []; //月均还款
			let perPri = parseFloat(perPrice);
			let perArea = parseFloat(area);
			let perLoan = parseFloat(loan);
			let perPercentage = parseFloat(percentage);
			let PerYear = parseFloat(year);
			let perTnterest = parseFloat(interest) / 100;
			uni.showToast({
				title: '计算中...',
				icon: 'loading',
				duration: 1000
			});
			if (this.curEqual1item == 'equal1Interest') {
				//等额本息
				let commonNum = Math.pow(1 + perTnterest / 12, PerYear * 12); //公共部分
				if (this.iconIndex == 'area') {
					let houseAmout = perPri * perArea; //房款总额
					let loanAmount = houseAmout * perPercentage; //贷款总额
					let repayAmount = ((((loanAmount * perTnterest) / 12) * commonNum) / (commonNum - 1)) * PerYear * 12; //还款总额
					let repayInterest = repayAmount - loanAmount; //支付利息
					let firstRepay = houseAmout - loanAmount; //首期付款
					let loanMonth = PerYear * 12; //贷款月数
					let repayMonth = (((loanAmount * perTnterest) / 12) * commonNum) / (commonNum - 1); //月均还款
					monthArray.push(repayMonth.toFixed(2));
					setTimeout(() =>{
						this.houseAmout = houseAmout.toFixed(2);
						this.loanAmount = loanAmount.toFixed(2);
						this.repayAmount = repayAmount.toFixed(2);
						this.repayInterest = repayInterest.toFixed(2);
						this.firstRepay = firstRepay.toFixed(2);
						this.loanMonth = loanMonth;
						this.monthArray = monthArray;
					}, 1000);
				}
				if (this.iconIndex == 'loan') {
					let houseAmout = '略'; //房款总额
					let loanAmount = perLoan; //贷款总额
					let repayAmount = ((((perLoan * perTnterest) / 12) * commonNum) / (commonNum - 1)) * PerYear * 12;
					//还款总额
					let repayInterest = repayAmount - perLoan; //支付利息
					let firstRepay = 0; //首期付款
					let loanMonth = PerYear * 12; //贷款月数
					let repayMonth = (((perLoan * perTnterest) / 12) * commonNum) / (commonNum - 1); //月均贷款
					monthArray.push(repayMonth.toFixed(2));
					setTimeout(()=> {
						this.houseAmout = houseAmout;
						this.loanAmount = loanAmount.toFixed(2);
						this.repayAmount = repayAmount.toFixed(2);
						this.repayInterest = repayInterest.toFixed(2);
						this.firstRepay = firstRepay.toFixed(2);
						this.loanMonth = loanMonth;
						this.monthArray = monthArray;
					}, 1000);
				}
			}
			if (this.curEqual1item == 'equal1Money') {
				//等额本金
				if (this.iconIndex == 'area') {
					let houseAmout = perPri * perArea; //房款总额
					let loanAmount = houseAmout * perPercentage; //贷款总额
					let repayAmount = ((PerYear * 12 + 1) * loanAmount * perTnterest) / 24 + loanAmount; //还款总额
					let repayInterest = ((PerYear * 12 + 1) * loanAmount * perTnterest) / 24; //支付利息
					let firstRepay = houseAmout - loanAmount; //首期付款
					let loanMonth = PerYear * 12; //贷款月数
					let commonforPart = loanAmount / loanMonth; //公共部分1
					let commonendPart = loanAmount; //公共部分2
					for (var i = 1; i < loanMonth + 1; i++) {
						if (i == 1) {
							monthArray.push((commonforPart + (commonendPart * perTnterest) / 12).toFixed(2));
						} else {
							monthArray.push((commonforPart + (commonendPart * (1 - (i - 1) / loanMonth) * perTnterest) / 12).toFixed(2));
						}
					}
					setTimeout(()=> {
						this.houseAmout = houseAmout.toFixed(2);
						this.loanAmount = loanAmount.toFixed(2);
						this.repayAmount = repayAmount.toFixed(2);
						this.repayInterest = repayInterest.toFixed(2);
						this.firstRepay = firstRepay.toFixed(2);
						this.loanMonth = loanMonth;
						this.monthArray = monthArray;
					}, 1000);
				}
				if (this.iconIndex == 'loan') {
					let houseAmout = '略'; //房款
					let loanAmount = perLoan; //贷款总额
					let commonnum = (PerYear * 12 + 1) * perLoan * perTnterest;
					let repayAmount = commonnum / 24 + perLoan; //还款总额
					let repayInterest = ((PerYear * 12 + 1) * perLoan * perTnterest) / 24; //支付利息
					let firstRepay = 0; //首期付款
					let loanMonth = PerYear * 12; //贷款月数
					let commonforPart = perLoan / loanMonth; //公共部分1
					let commonendPart = perLoan; //公共部分2
					for (var i = 1; i < loanMonth + 1; i++) {
						if (i == 1) {
							monthArray.push((commonforPart + (commonendPart * perTnterest) / 12).toFixed(2));
						} else {
							monthArray.push((commonforPart + (commonendPart * (1 - (i - 1) / loanMonth) * perTnterest) / 12).toFixed(2));
						}
					}
					setTimeout(()=> {
						this.houseAmout = houseAmout;
						this.loanAmount = loanAmount.toFixed(2);
						this.repayAmount = repayAmount.toFixed(2);
						this.repayInterest = repayInterest.toFixed(2);
						this.firstRepay = firstRepay.toFixed(2);
						this.loanMonth = loanMonth;
						this.monthArray = monthArray;
					}, 1000);
				}
			}
		},
		//组合贷款
		combinationCaculate(business, fund, year, buseInterest, fundInterest) {
			let monthArray = []; //月均还款
			let perBusiness = parseFloat(business);
			let perFund = parseFloat(fund);
			let perYear = parseFloat(year);
			let perBuseInterest = parseFloat(buseInterest) / 100;
			let perFundInterest = parseFloat(fundInterest) / 100;
			uni.showToast({
				title: '计算中...',
				icon: 'loading',
				duration: 1000
			});
			if (this.curEqual1item == 'equal1Interest') {
				let commonNumB = Math.pow(1 + perBuseInterest / 12, perYear * 12); //公共部分1
				let commonNumF = Math.pow(1 + perFundInterest / 12, perYear * 12); //公共部分2
				let houseAmout = '略'; //房款总额
				let loanAmount = perBusiness + perFund; //贷款总额
				let businessRepay = ((((perBusiness * perBuseInterest) / 12) * commonNumB) / (commonNumB - 1)) * perYear * 12;
				let funRepay = ((((perFund * perFundInterest) / 12) * commonNumF) / (commonNumF - 1)) * perYear * 12;
				let repayAmount = businessRepay + funRepay; //还款总额
				let businessPayInter = businessRepay - perBusiness;
				let fundPayInter = funRepay - perFund;
				let repayInterest = businessPayInter + fundPayInter; //支付利息
				let firstRepay = 0; //首期付款
				let loanMonth = perYear * 12; //贷款月数
				let businePayMonth = (((perBusiness * perBuseInterest) / 12) * commonNumB) / (commonNumB - 1);
				let fundPayMonth = (((perFund * perFundInterest) / 12) * commonNumF) / (commonNumF - 1);
				let repayMonth = businePayMonth + fundPayMonth; //月均贷款
				monthArray.push(repayMonth.toFixed(2));
				setTimeout(()=> {
					this.houseAmout = houseAmout;
					this.loanAmount = loanAmount.toFixed(2);
					this.repayAmount = repayAmount.toFixed(2);
					this.repayInterest = repayInterest.toFixed(2);
					this.firstRepay = firstRepay;
					this.loanMonth = loanMonth;
					this.monthArray = monthArray;
				}, 1000);
			}
			if (this.curEqual1item == 'equal1Money') {
				let commonnumB = ((perYear * 12 + 1) * perBusiness * perBuseInterest) / 24;
				let commonnumF = ((perYear * 12 + 1) * perFund * perFundInterest) / 24;
				let commonforPartB = perBusiness / (perYear * 12);
				let commonendPartB = perBusiness;
				let commonforPartF = perFund / (perYear * 12);
				let commonendPartF = perFund;
				let houseAmout = '略'; //房款总额
				let loanAmount = perBusiness + perFund; //贷款总额
				let repayAmount = commonnumB + perBusiness + (commonnumF + perFund); //还款总额
				let businessPayInter = ((perYear * 12 + 1) * perBusiness * perBuseInterest) / 24;
				let fundPayInter = ((perYear * 12 + 1) * perFund * perFundInterest) / 24;
				let repayInterest = businessPayInter + fundPayInter; //支付利息
				let firstRepay = 0; //首期付款
				let loanMonth = perYear * 12; //贷款月数
				for (var i = 1; i < loanMonth + 1; i++) {
					if (i == 1) {
						monthArray.push((commonforPartB + (commonendPartB * perBuseInterest) / 12 + (commonforPartF + (commonendPartF * perBuseInterest) / 12)).toFixed(2));
					} else {
						monthArray.push(
							(
								commonforPartB +
								(commonendPartB * (1 - (i - 1) / loanMonth) * perFundInterest) / 12 +
								(commonforPartF + (commonendPartF * (1 - (i - 1) / loanMonth) * perFundInterest) / 12)
							).toFixed(2)
						);
					}
				}
				setTimeout(()=> {
					this.houseAmout = houseAmout;
					this.loanAmount = loanAmount.toFixed(2);
					this.repayAmount = repayAmount.toFixed(2);
					this.repayInterest = repayInterest.toFixed(2);
					this.firstRepay = firstRepay.toFixed(2);
					this.loanMonth = loanMonth;
					this.monthArray = monthArray;
				}, 1000);
			}
		}
	}
};
</script>

<style lang="scss">
.container {
	width: 100%;
	margin: 0 auto;
	overflow: hidden;
	background-color: #FFFFFF;
}
.container .titleTip {
	width: 100%;
	height: 80upx;
	line-height: 80upx;
	font-size: 28upx;
	font-weight: bold;
	text-indent: 40upx;
	background: #e8e8e8;
}

.header {
	width: 100%;
	margin: 0 auto;
}

.headerInner {
	width: 95%;
	margin: 0 auto;
	display: flex;
	flex-direction: row;
	align-items: center;
	justify-content: center;
	border-bottom: 1upx solid #ccc;
}

.radio-group {
	font-size: 28upx;
	color: #4c4c4c;
	margin: 20upx 0 20upx 10upx;
}

.radio {
	width: calc(100% / 3);
	align-items: center;
	justify-content: center;
	padding: 20upx 0;
	display: flex;
}

.radio1 {
	width: calc(100% / 3);
	align-items: center;
	justify-content: center;
	padding: 20upx 0;
	margin-right: 20upx;
}

.radio text {
	color: #4c4c4c;
	font-size: 26upx;
	margin-left: 10upx;
}

.content {
	width: 100%;
	margin: 30upx auto 0;
}

.title {
	width: 95%;
	margin: 0 auto;
	font-size: 30upx;
	color: #4c4c4c;
}

.contentInner {
	width: 95%;
	margin: 30upx auto 0;
}

.contentInner view.innerTip {
	color: #4c4c4c;
	font-size: 28upx;
	margin-top: 20upx;
	display: flex;
}

.contentInner view.innerTip text {
	margin-left: 20upx;
}

.area {
	width: 100%;
}

.areaItem {
	display: flex;
	flex-direction: row;
	align-items: center;
	margin-top: 30upx;
}

.areaItem text:nth-child(1) {
	font-size: 26upx;
	color: #4c4c4c;
	margin-right: 30upx;
	width: 150upx;
	text-align: right;
}

.areaItem text:nth-child(3) {
	font-size: 26upx;
	color: #4c4c4c;
}

.areaItem input {
	color: #09bb07;
	border: 1upx solid #09bb07;
	width: 220upx;
	padding: 5upx 30upx;
	margin-right: 20upx;
	border-radius: 8upx;
	font-size: 28upx;
}

.rect {
	color: #09bb07;
	border: 1upx solid #09bb07;
	width: 320upx;
	text-align: center;
	display: inline-block;
	font-size: 26upx;
	border-radius: 8upx;
	padding: 15upx 30upx;
	position: relative;
}

.rect .triangle {
	position: absolute;
	right: 10upx;
	top: 0upx;
	bottom: 0upx;
	margin: auto auto;
	width: 0;
	height: 0;
	border-left: 8upx solid transparent;
	border-right: 8upx solid transparent;
	border-top: 15upx solid #09bb07;
}

.loan {
	width: 100%;
	margin: 0 auto;
}

.line {
	width: 100%;
	height: 2upx;
	background: #ccc;
	margin: 40upx auto;
}

.contentMid {
	width: 100%;
	margin: 0 auto;
}

.percentInput {
	width: 190upx;
}

.percentText {
	width: 340upx;
	/* height:65upx; */
	border: 1upx solid #09bb07;
	border-radius: 8upx;
	margin-right: 20upx;
	text-align: center;
	font-size: 28upx;
	color: #09bb07;
	line-height: 65upx;
}

.contentBom {
	width: 100%;
	display: flex;
	flex-direction: row;
	align-items: center;
}

.contentBom text {
	font-size: 28upx;
	color: #4c4c4c;
	text-align: right;
	display: inline-block;
	width: 156upx;
	margin-right: 30upx;
}

.contentBom view {
	margin-left: 30upx;
}

.contentBom view text {
	margin-left: 20upx;
}

.contentBtn {
	width: 70%;
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin: 0 auto;
}

.contentBtn button {
	/* width: 170upx; */
	height: 60upx;
	line-height: 60upx;
	/* color: #fff; */
	font-size: 28upx;
	text-align: center;
	/* background: #09BB07; */
	margin: 0;
	border: 1upx solid #09bb07;
	border-radius: 8upx;
	/* padding:10upx 0; */
}

.contentBtn view {
	width: 170upx;
	height: 50upx;
	line-height: 50upx;
	color: #09bb07;
	font-size: 26upx;
	text-align: center;
	border: 1upx solid #09bb07;
	border-radius: 8upx;
}

.footer {
	width: 95%;
	margin: 30upx auto 0;
}

.footerInner {
	width: 100%;
	margin: 0 auto;
}

.footerTitle {
	color: #09bb07;
	font-size: 30upx;
	width: 100%;
	margin: 50upx 0 0 50upx;
}

.footerContent {
	width: 100%;
	margin: 30upx auto;
}

.footerItem {
	width: 100%;
	margin: 30upx auto;
	display: flex;
	flex-direction: row;
	align-items: center;
}

scroll-view {
	width: 100%;
}

scroll-view .footerItem:nth-child(1) {
	margin: 0 auto 30upx;
}

.footerItem text:nth-child(1) {
	color: #4c4c4c;
	font-size: 26upx;
	width: 210upx;
	text-align: right;
	margin-left: 50upx;
}

.footerItem text:nth-child(2) {
	color: #09bb07;
	font-size: 26upx;
	width: 300upx;
	height: 50upx;
	line-height: 50upx;
	text-align: center;
	border: 1upx solid #09bb07;
	border-radius: 8upx;
}

.footerItem text:nth-child(3) {
	font-size: 26upx;
	color: #4c4c4c;
	margin-left: 20upx;
}

.footerTip {
	width: 92%;
	margin: 30upx auto;
	color: #09bb07;
	font-size: 30upx;
}
</style>
